#include "../logger/log.h"
using namespace ns_logger;

void test_gloable()
{
    // 2.获取日志器
    LoggerPtr lg = getLogger("ansync_logger");
    // 3.调用输出
    const std::string msg = "测试gloable样例";
    lg->Debug("%s", msg.c_str());
    lg->Info("%s", msg.c_str());
    lg->Warning("%s", msg.c_str());
    lg->Error("%s", msg.c_str());
    lg->Fatal("%s", msg.c_str());
}

void test_root()
{
    //默认日志器
    const std::string msg = "测试root样例";
    DLOG("%s", msg.c_str());
    ILOG("%s", msg.c_str());
    ELOG("%s", msg.c_str());
    WLOG("%s", msg.c_str());
    FLOG("%s", msg.c_str());
}

int main()
{
    // 1.创建全局日志器
    std::shared_ptr<LoggerBuilde> builder(new GlobalLoggerBuilder());
    builder->BuildFormat("[%c][%p][%d{%H:%M:%S}]:%m%n");
    builder->BuildName("ansync_logger");
    builder->BuildType(LogType::ASYNC);
    builder->BuildSink<FileSink>("./log/async.text");
    builder->EnableUnSafe();
    builder->BuildSink<StdoutSink>();
    builder->build();
    test_gloable();
    test_root();
}